package cn.net.msg.cxf.webservice.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

import cn.net.msg.cxf.webservice.IExamsPaperWebService;
import cn.net.msg.model.PageView;
import cn.net.msg.model.ReturnNewExamFilesBean;
import cn.net.msg.model.TbExamFiles;
import cn.net.msg.service.TbExamFilesService;
import cn.net.msg.service.base.Order;

/**
 * <p>
 * FileName: ExamsPaperWebServiceImpl.java
 * </p>
 * <p>
 * Description: 考卷的cxf服务实现类
 * <p>
 * Copyright: surepassserver(c) 2012
 * </p>
 * <p>
 * @author Vic Su
 * </p>
 * <p>
 * @content andyliu900@gmail.com
 * </p>
 * <p>
 * @version 1.0
 * </p>
 * <p>
 * CreatDate: 2012-11-21 下午10:26:04
 * </p>
 * <p>
 * Modification History
 */

@WebService
@SOAPBinding(style = Style.RPC)
@SuppressWarnings("deprecation")
public class ExamsPaperWebServiceImpl implements IExamsPaperWebService{

    private static final long serialVersionUID = -7574227471454774126L;

    @Resource(name="tbExamFilesService")
    TbExamFilesService service;

    @Override
    public List<TbExamFiles> getExamsPapersForList(@WebParam(name = "maxresult")int maxresult,
            @WebParam(name = "currentpage")int currentpage, @WebParam(name = "userid") long userid,
            @WebParam(name = "searchCondition") String searchCondition) {

        List<TbExamFiles> list = new ArrayList<TbExamFiles>();

        //获取该人所属等级id
        int gradeid = service.getUserGradeId(userid);

        PageView<TbExamFiles> pageView = new PageView<TbExamFiles>(maxresult, currentpage);        
        List<HashMap<String,Object>> queryParams = new ArrayList<HashMap<String,Object>>();
        HashMap map_1 = new HashMap();
        map_1.put("opera", "le");
        map_1.put("field", "gradeId");
        map_1.put("value", gradeid);
        queryParams.add(map_1);

        if(searchCondition == null || "".equals(searchCondition)){
            list = service.getExamsPapersForList(pageView.getFirstResult(),pageView.getMaxresult(),queryParams,Order.DESC,"examCreattime");
        }else{
            HashMap map_2 = new HashMap();
            map_2.put("opera", "like");
            map_2.put("field", "examTitle");
            map_2.put("value", searchCondition); 
            queryParams.add(map_2);
            list = service.getExamsPapersForList(pageView.getFirstResult(),pageView.getMaxresult(),queryParams,Order.DESC,"examCreattime");
        } 

        return list;
    }
    
    @Override
    public List<ReturnNewExamFilesBean> getNewExamPapersForList(@WebParam(name = "userid")long userid) {
        List<ReturnNewExamFilesBean> returnNewExamFilesBean = service.getNewExamPapersForList(userid);
        return returnNewExamFilesBean;
    }
}
